import Router from "@koa/router";
import { Result } from "./factory/Result";
import { addTaskResult, listTaskResultMap } from "./routeHandler/taskResult";
import {
  addTask,
  clearAll,
  clearById,
  getTaskDetail,
  listTask,
} from "./routeHandler/task";
import { listTaskType } from "./routeHandler/taskType";

const router = new Router({
  prefix: "/api",
});

router.get("/", (ctx) => {
  ctx.body = Result.success("Hello world");
});

// 查询可执行的任务类型列表
router.post("/listTaskType", listTaskType);
// 查询构建结果记录，以对象的形式返回
router.post("/listTaskResultMap", listTaskResultMap);
// 添加一条任务记录，会尝试触发任务调度执行
router.post("/addTask", addTask);
// 查询任务详情列表
router.post("/listTask", listTask);
// 查询任务详情
router.post("/taskDetail", getTaskDetail);
// 清理全部
router.post("/clearAll", clearAll);
// 根据id删除
router.post("/clearByTaskId", clearById);

export { router };
